{extend name='table'}

{block name='button'}
<button data-table-id="EmployeeTable" data-modal='{:url("add")}?company_id={$company_id|default=""}' class='layui-btn layui-btn-sm layui-btn-primary'>添加员工</button>
<button data-table-id="EmployeeTable" data-action='{:url("delete")}' data-rule="id#{id}" data-confirm="确定要批量删除员工吗？" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
{/block}

{block name="content"}
<div class="think-box-shadow">
    <fieldset>
        <legend>{:lang('条件搜索')}</legend>
        <form class="layui-form layui-form-pane form-search" action="{:url()}" onsubmit="return false" method="get" autocomplete="off">
            <input type="hidden" name="company_id" value="{$company_id|default=''}">
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">公司</label>
                <div class="layui-input-inline">
                    <select name="company_id" class="layui-select">
                        <option value="">全部公司</option>
                        {volist name="companies" id="company"}
                        <option value="{$company.id}" {if condition="$company_id eq $company.id"}selected{/if}>{$company.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">车牌号</label>
                <div class="layui-input-inline">
                    <input name="plate_number" value="{$get.plate_number|default=''}" placeholder="请输入车牌号" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            </div>
        </form>
    </fieldset>
    <table id="EmployeeTable" data-url="{:url('get')}?company_id={$company_id|default=''}" data-line="3" data-target-search="form.form-search"></table>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        $('#EmployeeTable').layTable({
            even: true, height: 'full',
            sort: {field: 'id', type: 'desc'},
            cols: [[
                {checkbox: true, fixed: true},
                {field: 'id', title: 'ID', hide: true},
                {field: 'company_name', title: '公司名称', minWidth: 120},
                {field: 'name', title: '员工名称', minWidth: 120},
                {field: 'plate_number', title: '车牌号', minWidth: 120},
                {field: 'status', title: '员工状态', minWidth: 100, templet: function (d) {
                    return d.status ? '正常' : '禁用';
                }},
                {toolbar: '#toolbar', title: '操作', minWidth: 120}
            ]]
        });
    });
</script>

<!-- 数据操作工具条模板 -->
<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-primary layui-btn-sm" data-event-dbclick data-title="编辑员工" data-modal='{:url("edit")}?id={{d.id}}'>编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-sm" data-confirm="确定要删除员工吗?" data-action="{:url('delete')}" data-value="id#{{d.id}}">删除</a>
</script>
{/block}
